#!/bin/bash

# 检查 /boot/grub2/grub.cfg 文件权限
if [ -f /boot/grub2/grub.cfg ]; then
    # 获取文件权限、用户ID和组ID
    file_stat=$(stat -L -c "%a %u %g" /boot/grub2/grub.cfg 2>/dev/null)
    
    if [ "$file_stat" = "600 0 0" ]; then
        echo "[PASS] /boot/grub2/grub.cfg 权限配置正确"
    else
        echo "[FAIL] /boot/grub2/grub.cfg 权限配置不正确，应设置为 (600 root:root)"
    fi
else
    echo "[FAIL] /boot/grub2/grub.cfg 文件不存在"
    exit 1
fi

# 检查 /boot/grub2/user.cfg 文件权限
if [ -f /boot/grub2/user.cfg ]; then
    file_stat=$(stat -L -c "%a %u %g" /boot/grub2/user.cfg 2>/dev/null)
    
    if [ "$file_stat" = "600 0 0" ]; then
        echo "[PASS] /boot/grub2/user.cfg 权限配置正确"
    else
        echo "[FAIL] /boot/grub2/user.cfg 权限配置不正确，应设置为 (600 root:root)"
    fi
else
    echo "[FAIL] /boot/grub2/user.cfg 文件不存在"
    exit 1
fi
